import { http } from '@/utils/http'
// todo 左上角缺培训和通知的返回值案例 空数组

export interface ExamItem {
  examId: number
  examTitle: string | null
  beginTime: string
  endTime: string
  isOpenScore: number
  allowTimes: number
  isPublishScore: number
  isAntiCheating: number
  allowLeaveTimes: number
  timeLength: number
  totalScore: number
  realname: string | null
}

export interface NoticeItem {
  id: number
  title: string
  content: string
  isReadComplete: boolean
  noticeCategoryName: string
  time: string
  endtime: string
}

/* 培训 */
export const getTrainList = () => {
  return http.get('/api/MP/GetPlanbyUser')
}

/* 考试 */
export const getExamList = (): Promise<IResData<ExamItem[]>> => {
  return http.get<ExamItem[]>('/api/MP/GetExambyUser')
}

/* 通知 type 0未读 1已读 */
export const getNoticeList = (type: number): Promise<IResData<NoticeItem[]>> => {
  return http.get<NoticeItem[]>('/api/MP/GetNotNoticeList', { type })
}

// 获取通知详情
export const getNoticeDetail = (id: number): Promise<IResData<NoticeItem>> => {
  return http.get<NoticeItem>('/api/MP/GetNotNoticeDetail', { id })
}
